﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using System.Data;

namespace EDMS
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
           
            }
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (CMSUser.Login(txtLoginName.Text, txtPwd.Text, txtLoginName.Text))
            {
                Session["username"] = txtLoginName.Text;
                using(DataClassesDataContext lqdb = new DataClassesDataContext())
                {
                    User u = lqdb.User.FirstOrDefault(o => o.LoginName == txtLoginName.Text && o.PassWord == txtPwd.Text || o.UserName ==  txtLoginName.Text);
                    Session["Xjbh"] = u.Xjbh;
                }
                
                Response.Redirect("~/Index.aspx");
            }
        }
    }
}